<?php

$pic_id=$_GET['pic_id'];


if (isset($_POST['type']) && $_POST['type'] == "insert")
{
  $name = $_POST['name'];
  $link_to = $_POST['link_to'];
  $pic_x = $_POST['pic_x'];
  $pic_y = $_POST['pic_y'];
  $sql = "INSERT INTO image_tag (name,pic_id,link_to,pic_x,pic_y) VALUES ('$name',$pic_id,$link_to,$pic_x,$pic_y)";
  $qry = mysql_query($sql);
}

if (isset($_POST['type']) && $_POST['type'] == "remove")
{
  $tag_id = $_POST['tag_id'];
  $sql = "DELETE FROM image_tag WHERE id = '".$tag_id."'";
  $qry = mysql_query($sql);
}


// fetch all tags
$sql = "SELECT * FROM image_tag WHERE pic_id = '".$pic_id."' ORDER BY id DESC";
$qry = mysql_query($sql);
$rs = mysql_fetch_array($qry);


if ($rs){
  do{
    $id[] = $rs['id']; 
	?><li rel="<?php echo $rs['id'] ?>"><?php echo ucfirst($rs['name']); ?> <a class="remove"><i class="icon-trash"></i></a></li>
  <?php }while($rs = mysql_fetch_array($qry));

}
?>


	
</div>

 <script> 
  $(document).ready(function(){
	
	$('#taglist li').live('click',function(event){	
    	id = $(this).attr("rel");
		$('#view_' + id).show();
    });
	</script>

